package main

import (
	"fmt"
	"time"
)

func MyAsyncFunc(num int64) chan int {
	r := make(chan int)
	go func() {
		defer close(r)
		time.Sleep(time.Second * time.Duration(num))
		r <- 2
	}()
	return r
}

func main1() {
	now := time.Now()

	r, c := MyAsyncFunc(2), MyAsyncFunc(3)

	fmt.Println(<-r, <-c)
	fmt.Println(time.Since(now))
}

func race() {
	var r int
	select {
	case r = <-MyAsyncFunc(2):
	case r = <-MyAsyncFunc(3):
	}
	fmt.Println(r)
}
